/*
 * 作者		钱新才
 * 开发环境	Win7 Eclipse3.5 JDK1.6
 * 开发日期	2011-11-16
 */
package org.ufinity.hsms.common.utils;
import org.ufinity.hsms.R;
import org.ufinity.hsms.common.application.HSMApplication;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;

public class SystemUtils {
	
	/**
	 * 退出
	 * @param context
	 * @param application
	 */
	public static void openOptionsDialog(final Context context,final HSMApplication application) {
		new AlertDialog.Builder(context).setTitle(R.string.point).setMessage(
				R.string.isExit).setPositiveButton(R.string.ok,
				new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface arg0, int arg1) {
						application.exit();
					}
				}).setNegativeButton(R.string.cancel,
				new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface arg0, int arg1) {
					}

				}).show();

	}
	
	
	/**
	 * 退出
	 * @param context
	 * @param application
	 */
	public static void openOptionsDialog(final Context context) {
		new AlertDialog.Builder(context).setTitle(R.string.point).setMessage(
				R.string.isExit).setPositiveButton(R.string.ok,
				new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface arg0, int arg1) {
						System.exit(0);
					}
				}).setNegativeButton(R.string.cancel,
				new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface arg0, int arg1) {
					}

				}).show();

	}
	
	/***
	 * home
	 * @param context
	 */
	public static void home(Context context){
		Intent intent = new Intent(Intent.ACTION_MAIN);
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		intent.addCategory(Intent.CATEGORY_HOME);
		context.startActivity(intent);
	}

}
